home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / The GIMP 2.2.8 / gimp-2.2.8-i586-setup.exe / {app} / share / gimp / 2.0 / scripts / xach-effect.scm < prev   
Encoding:
Text File  |  2005-06-30  |  4.6 KB  |  135 lines

  1.  
  2.  
  3. ; The GIMP -- an image manipulation program
  4. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  5. ; xach effect script
  6. ; Copyright (c) 1997 Adrian Likins
  7. ; aklikins@eos.ncsu.edu
  8. ;
  9. ; based on a idea by Xach Beane <xach@mint.net>
  10. ;
  11. ;
  12. ; This program is free software; you can redistribute it and/or modify
  13. ; it under the terms of the GNU General Public License as published by
  14. ; the Free Software Foundation; either version 2 of the License, or
  15. ; (at your option) any later version.
  16. ; This program is distributed in the hope that it will be useful,
  17. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19. ; GNU General Public License for more details.
  20. ; You should have received a copy of the GNU General Public License
  21. ; along with this program; if not, write to the Free Software
  22. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  23.  
  24.  
  25. (define (script-fu-xach-effect image
  26.                    drawable
  27.                    hl-offset-x
  28.                    hl-offset-y
  29.                    hl-color
  30.                    hl-opacity-comp
  31.                    ds-color
  32.                    ds-opacity
  33.                    ds-blur
  34.                    ds-offset-x
  35.                    ds-offset-y
  36.                    keep-selection)
  37.   (let* ((ds-blur (max ds-blur 0))
  38.      (ds-opacity (min ds-opacity 100))
  39.      (ds-opacity (max ds-opacity 0))
  40.      (type (car (gimp-drawable-type-with-alpha drawable)))
  41.      (image-width (car (gimp-image-width image)))
  42.      (hl-opacity (list hl-opacity-comp hl-opacity-comp hl-opacity-comp))
  43.      (image-height (car (gimp-image-height image))))
  44.  
  45.     (gimp-context-push)
  46.  
  47.     (gimp-image-undo-group-start image)
  48.     (gimp-layer-add-alpha drawable)
  49.  
  50.     (if (= (car (gimp-selection-is-empty image)) TRUE)
  51.     (begin
  52.       (gimp-selection-layer-alpha drawable)
  53.       (set! active-selection (car (gimp-selection-save image)))
  54.       (set! from-selection FALSE))
  55.     (begin
  56.       (set! from-selection TRUE)
  57.       (set! active-selection (car (gimp-selection-save image)))))
  58.  
  59.     (set! hl-layer (car (gimp-layer-new image image-width image-height type "Highlight" 100 NORMAL-MODE)))
  60.     (gimp-image-add-layer image hl-layer -1)
  61.  
  62.     (gimp-selection-none image)
  63.     (gimp-edit-clear hl-layer)
  64.     (gimp-selection-load active-selection)
  65.     
  66.     (gimp-context-set-background hl-color)
  67.     (gimp-edit-fill hl-layer BACKGROUND-FILL)
  68.     (gimp-selection-translate image hl-offset-x hl-offset-y)
  69.     (gimp-edit-fill hl-layer BACKGROUND-FILL)
  70.     (gimp-selection-none image)
  71.     (gimp-selection-load active-selection)
  72.     
  73.     (set! mask (car (gimp-layer-create-mask hl-layer ADD-WHITE-MASK)))
  74.     (gimp-layer-add-mask hl-layer mask)
  75.     
  76.     (gimp-context-set-background hl-opacity)
  77.     (gimp-edit-fill mask BACKGROUND-FILL)
  78.  
  79.     (set! shadow-layer (car (gimp-layer-new image
  80.                         image-width
  81.                         image-height
  82.                         type
  83.                         "Shadow"
  84.                         ds-opacity
  85.                         NORMAL-MODE)))
  86.     (gimp-image-add-layer image shadow-layer -1)
  87.     (gimp-selection-none image)
  88.     (gimp-edit-clear shadow-layer)
  89.     (gimp-selection-load active-selection)
  90.     (gimp-selection-translate image ds-offset-x ds-offset-y)
  91.     (gimp-context-set-background ds-color)
  92.     (gimp-edit-fill shadow-layer BACKGROUND-FILL)
  93.     (gimp-selection-none image)
  94.     (plug-in-gauss-rle 1 image shadow-layer ds-blur TRUE TRUE)
  95.     (gimp-selection-load active-selection)
  96.     (gimp-edit-clear shadow-layer)
  97.     (gimp-image-lower-layer image shadow-layer)
  98.  
  99.     (if (= keep-selection FALSE)
  100.     (gimp-selection-none image))
  101.  
  102.     (gimp-image-set-active-layer image drawable)
  103.     (gimp-image-remove-channel image active-selection)
  104.     (gimp-image-undo-group-end image)
  105.     (gimp-displays-flush)
  106.  
  107.     (gimp-context-pop)))
  108.  
  109.  
  110. (script-fu-register "script-fu-xach-effect"
  111.             _"_Xach-Effect..."
  112.             "Add a subtle translucent 3-d effect to the current selection or alpha channel"
  113.             "Adrian Likins <adrian@gimp.org>"
  114.             "Adrian Likins"
  115.             "9/28/97"
  116.             "RGB* GRAY*"
  117.             SF-IMAGE       "Image"                0
  118.             SF-DRAWABLE    "Drawable"             0
  119.             SF-ADJUSTMENT _"Highlight X offset"   '(-1 -100 100 1 10 0 1)
  120.             SF-ADJUSTMENT _"Highlight Y offset"   '(-1 -100 100 1 10 0 1)
  121.             SF-COLOR      _"Highlight color"      '(255 255 255)
  122.             SF-ADJUSTMENT _"Highlight opacity"    '(66 0 255 1 10 0 0)
  123.             SF-COLOR      _"Drop shadow color"    '(0 0 0)
  124.             SF-ADJUSTMENT _"Drop shadow opacity"  '(100 0 100 1 10 0 0)
  125.             SF-ADJUSTMENT _"Drop shadow blur radius" '(12 0 255 1 10 0 1)
  126.             SF-ADJUSTMENT _"Drop shadow X offset" '(5 0 255 1 10 0 1)
  127.             SF-ADJUSTMENT _"Drop shadow Y offset" '(5 0 255 1 10 0 1)
  128.             SF-TOGGLE     _"Keep selection"       TRUE)
  129.  
  130. (script-fu-menu-register "script-fu-xach-effect"
  131.              _"<Image>/Script-Fu/Shadow")
  132.